home *** CD-ROM | disk | FTP | other *** search
- //****************************************************************//
- // Filename: TextMeasure.cpp
- // Autor: Christian Taulien of Strange Intelligence
- // Purpose: implementation of a class for measuring texts
- // Creation: 19. Mai 1998
- //****************************************************************//
-
- #include <clib/graphics_protos.h>
-
- #include "global.h"
- #include "TextMeasure.h"
-
- TextMeasureC::TextMeasureC(struct Screen *arg_poScreen)
- /*S*/
- {
- TRACE("Entry");
- // den TextFont-Ptr auf NULL und dann den Screen setzen
- m_poTextFont = NULL;
- setScreen(arg_poScreen);
- }
- /*E*/
- TextMeasureC::~TextMeasureC()
- /*S*/
- {
- TRACE("Entry");
- // einfach den Font auf NULL setzen
- setScreen(NULL);
- }
- /*E*/
- int TextMeasureC::getTextHeight()
- /*S*/
- {
- TRACE("Entry");
- if (!isOk())
- {
- return 8; // topaz-height
- } // if
-
- return m_poTextFont->tf_YSize;
- }
- /*E*/
- int TextMeasureC::getTextWidth(StringC &arg_roText)
- /*S*/
- {
- TRACE("Entry");
- if (!isOk())
- {
- return arg_roText.getLength()*8; // topaz-width
- } // if
-
- return TextLength(&m_oTextRP, (char *) arg_roText, arg_roText.getLength());
- }
- /*E*/
- void TextMeasureC::setScreen(struct Screen *arg_poScreen)
- /*S*/
- {
- TRACE("Entry");
- // wenn noch ein Font offen.
- if (m_poTextFont)
- {
- CloseFont(m_poTextFont);
- m_poTextFont = NULL;
- } // if
-
- InitRastPort(&m_oTextRP);
-
- if (arg_poScreen)
- {
- m_poTextFont = OpenFont(arg_poScreen->Font);
- if (isOk())
- {
- SetFont(&m_oTextRP, m_poTextFont);
- } // if
- } // if
- }
- /*E*/
-
-